Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move mocks to parent package to avoid import cycle #1078

Merged
merged 2 commits into from
Oct 5, 2021

Conversation

wongma7
Copy link
Contributor

@wongma7 wongma7 commented Oct 5, 2021

Is this a bug fix or adding new feature?

What is this PR about? / Why do we need it?
I would like to move the cloud mocks to pkg/cloud from pkg/driver because they belong in pkg/cloud but that results in import cycle because mock_cloud.go depends on pkg/cloud e.g. for cloud.DiskOptions. If I recall correctly they are in pkg/driver as a hack to avoid this import cycle.

# github.com/kubernetes-sigs/aws-ebs-csi-driver/pkg/cloud
package github.com/kubernetes-sigs/aws-ebs-csi-driver/pkg/cloud (test)
	imports github.com/kubernetes-sigs/aws-ebs-csi-driver/pkg/cloud/mocks
	imports github.com/kubernetes-sigs/aws-ebs-csi-driver/pkg/cloud: import cycle not allowed in test

It seems simplest to just get rid of the mocks package and let mocks live in same package as what they are mocking.

(This is part of some effort to reorganize pkg/cloud to be easily copyable/consumable from EFS repo, see also "Refactor pkg/cloud/metadata.go into pkg/cloud/metadata_*.go files" #1074)
What testing is done?

@k8s-ci-robot k8s-ci-robot added cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. labels Oct 5, 2021
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: wongma7

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-ci-robot k8s-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Oct 5, 2021
@nckturner
Copy link

I don't see any problem with this, other than a desire to keeping testing related resources separate from application logic. Another note would be that this package seems general enough to consider moving it to cloud-provider-aws and importing it from there to both driver repositories.

@nckturner
Copy link

/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Oct 5, 2021
@k8s-ci-robot k8s-ci-robot merged commit 869e7f5 into kubernetes-sigs:master Oct 5, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. lgtm "Looks good to me", indicates that a PR is ready to be merged. size/XL Denotes a PR that changes 500-999 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants